<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>确认订单</title>
    <link rel="stylesheet" type="text/css" href="shop/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="shop/css/confirm.css"/>
    <link rel="stylesheet" type="text/css" href="shop/css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="shop/css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="shop/css/loading.css"/>
	<link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
	<script src="shop/js/rem.js"></script>
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jrender/jrender.js"></script>
	<script src="/js/plugins/dialog/dialog.min.js"></script>
	<script src="/js/common.js"></script>
	<script type="text/javascript">
		sessionStorage.url = "confirm";
		$(function () {
		    var did;//订单id
            var hotelId;
            var id = getParams().id;
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300)
			//获取用户id
            var user = JSON.parse(sessionStorage.getItem("user"));
            $(".info").renderValues(user);

            //通过id查询对应酒店
			$.get("/hotels/catalogs/"+id,function (data) {
                $(".travels").renderValues(data, {
                    handle: function (ele, value) {
                        $(ele).attr("href", "/shop/zhifu.html?id=" + value);
                    }
                })

            },"json");

            //点击提交按钮时,要保存订单信息,并跳转到订单页面
            $(".saveOrderBtn").click(function () {
                //查出对应id的酒店
                $.get("/hotels/catalogs/" + id,function (data) {
                    hotelId= data.id;//酒店的id
                    var orderNumber = guid();//生成的uuid

                    var json ={orderNumber:orderNumber,userId:user.id,state:0,hotelId:hotelId}
                    // 保存订单信息
                    $.post("/hotels/hotelOrders",json,function (data) {
                        if(data.success){
                            //订单保存成功,要查出此订单的id

                            $.get("/hotels/"+orderNumber,function (ele) {
                                did = ele.id;
                                console.log(did);
                                //调到支付页面
                                window.location.href="/hotelOrder.html?id="+did;
                            });
                        }else{
                            $(document).dialog({
                                style:"IOS",
                                titleShow:false,
                                content:data.msg,
                                autoClose:1500
                            });
                        }


                    });
                });




            });

        });
        function guid() {
            return 'xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/[xy]/g, function(c) {
                var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
                return v.toString(16);
            });
        }
	</script>
</head>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
	<body>
		<!--header star-->
		<header class="mui-bar mui-bar-nav" id="header">
			<a class="btn" href="javascript:history.go(-1)">
	            <i class="iconfont icon-fanhui"></i>
	        </a>
	        <div class="top-sch-box top-sch-boxtwo flex-col">
	                      确认订单
	        </div>
	    </header>
	    <!--header end-->
	    
	    <div class="warp warptwo clearfloat">
	    	<div class="confirm clearfloat">
	    		<div class="add clearfloat box-s info">
	    			<a href="address.html">
		    			<div class="left clearfloat fl">
		    				<i class="iconfont icon-dizhi1"></i>
		    			</div>
		    			<div class="middle clearfloat fl">
		    				<p class="tit">
		    					订单人：<spn render-html="nickName"></spn>
		    				</p>
		    			</div>
		    			<div class="left clearfloat fr">
		    				<i class="iconfont icon-jiantou1"></i>
		    			</div>
	    			</a>
	    		</div>
	    		<div class="lie clearfloat travels">
					<a href="detail.html">
						<div class="tu clearfloat fl">
							<img render-src="coverUrl"/>
						</div>
					</a>
					<div class="right clearfloat fl">
						<a href="detail.html">
							<p class="tit over" render-html="name"></p>
						</a>
						<div class="xia clearfloat">
							<a href="detail.html">
								<p class="jifen fl over" render-html="price"></p>
							</a>
							<span class="fr db">×1</span>
						</div>
					</div>
				</div>
				<div class="gmshu clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">购买数量</p>
			     		<div class="you clearfloat fr">
			     			<ul>
			     				<li><img src="images/jian.jpg"/></li>
			     				<li>1</li>
			     				<li><img src="images/jia.jpg"/></li>
			     			</ul>
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu gmshutwo clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">发票信息</p>
			     		<div class="you clearfloat fr">
			     			<div class="xuan clearfloat">
			     				<div class="radiotwo" > 
								    <label>
								        <input type="radio" name="fapiao" value="" checked/>
								        <div class="option"></div>
								        <span class="opt-text">需要发票</span>
								    </label>
								</div>
			     			</div>
		    				<div class="xuan clearfloat">
			     				<div class="radiotwo" > 
								    <label>
								        <input type="radio" name="fapiao" value=""/>
								        <div class="option"></div>
								        <span class="opt-text">不需要发票</span>
								    </label>
								</div>
			     			</div>
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu gmshuthree clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">买家留言</p>
			     		<div class="you clearfloat fl">
			     			<input type="text" name="" id="" value="" class="text" placeholder="选填 对本次交易需求给商家留言" />
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu clearfloat box-s fl travels">
					<p class="fr">共1晚   合计<samp render-html="price"></samp>元</p>
		     	</div>
		     	
	    	</div>
	    </div>	    
	    
		<!--settlement star-->
	    <div class="settlement clearfloat travels">
	    	<div class="zuo clearfloat fl box-s">
				<p class="fr">共1晚   合计<samp render-html="price"></samp>元</p>
	    	</div>
	    	<a class="fl db saveOrderBtn" >
	    		提交订单
	    	</a>
	    </div>
	    <!--settlement end-->
	    
	</body>
	
</html>
